
var express = require('express');
var router = express.Router();
var sqlQuery = require('../../../module/sql');
var jiami = require('../../../module/jiami');



/* GET users listing. */
router.get('/',async function (req, res, next) {
  //获取用户名

  let userid = req.query.id;
  console.log(req.query.id)
  let sqlStr = "select * from user where id = ?";
  let result = await sqlQuery(sqlStr,[userid])
  let user = result[0]
  let options = {user}
  res.render('admin/user/setup',options);

});


//获取修改的用户信息
router.post('/',async(req,res)=>{
  let password = jiami(req.body.password)
  let username = req.body.username
  //更新数据
  let sqlStr = "update user set password=? where username=? ";
  await sqlQuery(sqlStr,[password,username]);
      res.json({
        state:"ok",
        content:"密码修改成功"
      })
})


module.exports = router;
